package com.example.an.simplemusic;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button button= (Button) findViewById(R.id.btn1);
        Button button1= (Button) findViewById(R.id.btn2);
        button.setOnClickListener(startIt);
        button1.setOnClickListener(stopIt);
    }
    private View.OnClickListener startIt=new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            Intent i=new Intent();
            i.setAction("START_AUDIO_SERVICE");
             i.setPackage("com.example.an.simplemusic");
            startService(i);

        }
    };

    private View.OnClickListener stopIt=new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            stopService(new Intent(MainActivity.this,Music.class));
            finish();
        }
    };
}
